{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "4cdbc2ec-9ada-4c7e-bc19-6dfa27b29b02",
   "metadata": {},
   "source": [
    "# Custom Histogram Bins Using the `breaks` Parameter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "69a974d4-6a4a-432a-95fc-15aa88854461",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "            <div id=\"kotlin_out_0\"></div>\n",
       "            <script type=\"text/javascript\">\n",
       "                            if(!window.kotlinQueues) {\n",
       "                window.kotlinQueues = {};\n",
       "            }\n",
       "            if(!window.kotlinQueues[\"DataFrame\"]) {\n",
       "                var resQueue = [];\n",
       "                window.kotlinQueues[\"DataFrame\"] = resQueue;\n",
       "                window[\"call_DataFrame\"] = function(f) {\n",
       "                    resQueue.push(f);\n",
       "                }\n",
       "            }\n",
       "            (function (){\n",
       "                var modifiers = [(function(script) {\n",
       "    script.src = \"https://cdn.jsdelivr.net/gh/Kotlin/dataframe@3db46ccccaa1291c0627307d64133317f545e6ae/core/src/main/resources/init.js\"\n",
       "    script.type = \"text/javascript\";\n",
       "})];\n",
       "                var e = document.getElementById(\"kotlin_out_0\");\n",
       "                modifiers.forEach(function (gen) {\n",
       "                    var script = document.createElement(\"script\");\n",
       "                    gen(script)\n",
       "                    script.addEventListener(\"load\", function() {\n",
       "                        window[\"call_DataFrame\"] = function(f) {f();};\n",
       "                        window.kotlinQueues[\"DataFrame\"].forEach(function(f) {f();});\n",
       "                        window.kotlinQueues[\"DataFrame\"] = [];\n",
       "                    }, false);\n",
       "                    script.addEventListener(\"error\", function() {\n",
       "                        window[\"call_DataFrame\"] = function(f) {};\n",
       "                        window.kotlinQueues[\"DataFrame\"] = [];\n",
       "                        var div = document.createElement(\"div\");\n",
       "                        div.style.color = 'darkred';\n",
       "                        div.textContent = 'Error loading resource DataFrame';\n",
       "                        document.getElementById(\"kotlin_out_0\").appendChild(div);\n",
       "                    }, false);\n",
       "                    \n",
       "                    e.appendChild(script);\n",
       "                });\n",
       "            })();\n",
       "            </script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "                <style>\n",
       "                :root {\n",
       "    --background: #fff;\n",
       "    --background-odd: #f5f5f5;\n",
       "    --background-hover: #d9edfd;\n",
       "    --header-text-color: #474747;\n",
       "    --text-color: #848484;\n",
       "    --text-color-dark: #000;\n",
       "    --text-color-medium: #737373;\n",
       "    --text-color-pale: #b3b3b3;\n",
       "    --inner-border-color: #aaa;\n",
       "    --bold-border-color: #000;\n",
       "    --link-color: #296eaa;\n",
       "    --link-color-pale: #296eaa;\n",
       "    --link-hover: #1a466c;\n",
       "}\n",
       "\n",
       ":root[theme=\"dark\"], :root [data-jp-theme-light=\"false\"], .dataframe_dark{\n",
       "    --background: #303030;\n",
       "    --background-odd: #3c3c3c;\n",
       "    --background-hover: #464646;\n",
       "    --header-text-color: #dddddd;\n",
       "    --text-color: #b3b3b3;\n",
       "    --text-color-dark: #dddddd;\n",
       "    --text-color-medium: #b2b2b2;\n",
       "    --text-color-pale: #737373;\n",
       "    --inner-border-color: #707070;\n",
       "    --bold-border-color: #777777;\n",
       "    --link-color: #008dc0;\n",
       "    --link-color-pale: #97e1fb;\n",
       "    --link-hover: #00688e;\n",
       "}\n",
       "\n",
       "p.dataframe_description {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe {\n",
       "    font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n",
       "    font-size: 12px;\n",
       "    background-color: var(--background);\n",
       "    color: var(--text-color-dark);\n",
       "    border: none;\n",
       "    border-collapse: collapse;\n",
       "}\n",
       "\n",
       "table.dataframe th, td {\n",
       "    padding: 6px;\n",
       "    border: 1px solid transparent;\n",
       "    text-align: left;\n",
       "}\n",
       "\n",
       "table.dataframe th {\n",
       "    background-color: var(--background);\n",
       "    color: var(--header-text-color);\n",
       "}\n",
       "\n",
       "table.dataframe td {\n",
       "    vertical-align: top;\n",
       "    white-space: nowrap;\n",
       "}\n",
       "\n",
       "table.dataframe th.bottomBorder {\n",
       "    border-bottom-color: var(--bold-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(odd) {\n",
       "    background: var(--background-odd);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(even) {\n",
       "    background: var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:hover {\n",
       "    background: var(--background-hover);\n",
       "}\n",
       "\n",
       "table.dataframe a {\n",
       "    cursor: pointer;\n",
       "    color: var(--link-color);\n",
       "    text-decoration: none;\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover > td a {\n",
       "    color: var(--link-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe a:hover {\n",
       "    color: var(--link-hover);\n",
       "    text-decoration: underline;\n",
       "}\n",
       "\n",
       "table.dataframe img {\n",
       "    max-width: fit-content;\n",
       "}\n",
       "\n",
       "table.dataframe th.complex {\n",
       "    background-color: var(--background);\n",
       "    border: 1px solid var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe .leftBorder {\n",
       "    border-left-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightBorder {\n",
       "    border-right-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightAlign {\n",
       "    text-align: right;\n",
       "}\n",
       "\n",
       "table.dataframe .expanderSvg {\n",
       "    width: 8px;\n",
       "    height: 8px;\n",
       "    margin-right: 3px;\n",
       "}\n",
       "\n",
       "table.dataframe .expander {\n",
       "    display: flex;\n",
       "    align-items: center;\n",
       "}\n",
       "\n",
       "/* formatting */\n",
       "\n",
       "table.dataframe .null {\n",
       "    color: var(--text-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe .structural {\n",
       "    color: var(--text-color-medium);\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .dataFrameCaption {\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .numbers {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe td:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "\n",
       "                </style>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "   <div id=\"aJ6oxu\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"library\">\n",
       "       if(!window.letsPlotCallQueue) {\n",
       "           window.letsPlotCallQueue = [];\n",
       "       }; \n",
       "       window.letsPlotCall = function(f) {\n",
       "           window.letsPlotCallQueue.push(f);\n",
       "       };\n",
       "       (function() {\n",
       "           var script = document.createElement(\"script\");\n",
       "           script.type = \"text/javascript\";\n",
       "           script.src = \"https://cdn.jsdelivr.net/gh/JetBrains/lets-plot@v4.8.1rc1/js-package/distr/lets-plot.min.js\";\n",
       "           script.onload = function() {\n",
       "               window.letsPlotCall = function(f) {f();};\n",
       "               window.letsPlotCallQueue.forEach(function(f) {f();});\n",
       "               window.letsPlotCallQueue = [];\n",
       "               \n",
       "               \n",
       "           };\n",
       "           script.onerror = function(event) {\n",
       "               window.letsPlotCall = function(f) {};\n",
       "               window.letsPlotCallQueue = [];\n",
       "               var div = document.createElement(\"div\");\n",
       "               div.style.color = 'darkred';\n",
       "               div.textContent = 'Error loading Lets-Plot JS';\n",
       "               document.getElementById(\"aJ6oxu\").appendChild(div);\n",
       "           };\n",
       "           var e = document.getElementById(\"aJ6oxu\");\n",
       "           e.appendChild(script);\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "            <div id=\"kotlin_out_1\"></div>\n",
       "            <script type=\"text/javascript\">\n",
       "                            if(!window.kotlinQueues) {\n",
       "                window.kotlinQueues = {};\n",
       "            }\n",
       "            if(!window.kotlinQueues[\"letsPlotJs\"]) {\n",
       "                var resQueue = [];\n",
       "                window.kotlinQueues[\"letsPlotJs\"] = resQueue;\n",
       "                window[\"call_letsPlotJs\"] = function(f) {\n",
       "                    resQueue.push(f);\n",
       "                }\n",
       "            }\n",
       "            (function (){\n",
       "                var modifiers = [(function(script) {\n",
       "    script.src = \"https://cdn.jsdelivr.net/gh/JetBrains/lets-plot@v4.8.1rc1/js-package/distr/lets-plot.min.js\"\n",
       "    script.type = \"text/javascript\";\n",
       "})];\n",
       "                var e = document.getElementById(\"kotlin_out_1\");\n",
       "                modifiers.forEach(function (gen) {\n",
       "                    var script = document.createElement(\"script\");\n",
       "                    gen(script)\n",
       "                    script.addEventListener(\"load\", function() {\n",
       "                        window[\"call_letsPlotJs\"] = function(f) {f();};\n",
       "                        window.kotlinQueues[\"letsPlotJs\"].forEach(function(f) {f();});\n",
       "                        window.kotlinQueues[\"letsPlotJs\"] = [];\n",
       "                    }, false);\n",
       "                    script.addEventListener(\"error\", function() {\n",
       "                        window[\"call_letsPlotJs\"] = function(f) {};\n",
       "                        window.kotlinQueues[\"letsPlotJs\"] = [];\n",
       "                        var div = document.createElement(\"div\");\n",
       "                        div.style.color = 'darkred';\n",
       "                        div.textContent = 'Error loading resource letsPlotJs';\n",
       "                        document.getElementById(\"kotlin_out_1\").appendChild(div);\n",
       "                    }, false);\n",
       "                    \n",
       "                    e.appendChild(script);\n",
       "                });\n",
       "            })();\n",
       "            </script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%useLatestDescriptors\n",
    "%use dataframe\n",
    "%use lets-plot(output=\"js, svg\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "bcf65a95-e080-4a75-886f-ab5bc4d94b4b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Lets-Plot Kotlin API v.4.11.3-SNAPSHOT. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.8.1rc1.\n",
       "Outputs: Web (HTML+JS), Static SVG (hidden)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "LetsPlot.getInfo()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9aa2130b-dbe6-4f4d-bca4-c6ff57a5d329",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "53940 x 10\n"
     ]
    },
    {
     "data": {
      "application/kotlindataframe+json": "{\"nrow\":5,\"ncol\":10,\"columns\":[\"carat\",\"cut\",\"color\",\"clarity\",\"depth\",\"table\",\"price\",\"x\",\"y\",\"z\"],\"is_formatted\":false,\"kotlin_dataframe\":[{\"carat\":0.23,\"cut\":\"Ideal\",\"color\":\"E\",\"clarity\":\"SI2\",\"depth\":61.5,\"table\":55.0,\"price\":326,\"x\":3.95,\"y\":3.98,\"z\":2.43},{\"carat\":0.21,\"cut\":\"Premium\",\"color\":\"E\",\"clarity\":\"SI1\",\"depth\":59.8,\"table\":61.0,\"price\":326,\"x\":3.89,\"y\":3.84,\"z\":2.31},{\"carat\":0.23,\"cut\":\"Good\",\"color\":\"E\",\"clarity\":\"VS1\",\"depth\":56.9,\"table\":65.0,\"price\":327,\"x\":4.05,\"y\":4.07,\"z\":2.31},{\"carat\":0.29,\"cut\":\"Premium\",\"color\":\"I\",\"clarity\":\"VS2\",\"depth\":62.4,\"table\":58.0,\"price\":334,\"x\":4.2,\"y\":4.23,\"z\":2.63},{\"carat\":0.31,\"cut\":\"Good\",\"color\":\"J\",\"clarity\":\"SI2\",\"depth\":63.3,\"table\":58.0,\"price\":335,\"x\":4.34,\"y\":4.35,\"z\":2.75}]}",
      "text/html": [
       "        <html>\n",
       "        <head>\n",
       "            <style type=\"text/css\">\n",
       "                :root {\n",
       "    --background: #fff;\n",
       "    --background-odd: #f5f5f5;\n",
       "    --background-hover: #d9edfd;\n",
       "    --header-text-color: #474747;\n",
       "    --text-color: #848484;\n",
       "    --text-color-dark: #000;\n",
       "    --text-color-medium: #737373;\n",
       "    --text-color-pale: #b3b3b3;\n",
       "    --inner-border-color: #aaa;\n",
       "    --bold-border-color: #000;\n",
       "    --link-color: #296eaa;\n",
       "    --link-color-pale: #296eaa;\n",
       "    --link-hover: #1a466c;\n",
       "}\n",
       "\n",
       ":root[theme=\"dark\"], :root [data-jp-theme-light=\"false\"], .dataframe_dark{\n",
       "    --background: #303030;\n",
       "    --background-odd: #3c3c3c;\n",
       "    --background-hover: #464646;\n",
       "    --header-text-color: #dddddd;\n",
       "    --text-color: #b3b3b3;\n",
       "    --text-color-dark: #dddddd;\n",
       "    --text-color-medium: #b2b2b2;\n",
       "    --text-color-pale: #737373;\n",
       "    --inner-border-color: #707070;\n",
       "    --bold-border-color: #777777;\n",
       "    --link-color: #008dc0;\n",
       "    --link-color-pale: #97e1fb;\n",
       "    --link-hover: #00688e;\n",
       "}\n",
       "\n",
       "p.dataframe_description {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe {\n",
       "    font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n",
       "    font-size: 12px;\n",
       "    background-color: var(--background);\n",
       "    color: var(--text-color-dark);\n",
       "    border: none;\n",
       "    border-collapse: collapse;\n",
       "}\n",
       "\n",
       "table.dataframe th, td {\n",
       "    padding: 6px;\n",
       "    border: 1px solid transparent;\n",
       "    text-align: left;\n",
       "}\n",
       "\n",
       "table.dataframe th {\n",
       "    background-color: var(--background);\n",
       "    color: var(--header-text-color);\n",
       "}\n",
       "\n",
       "table.dataframe td {\n",
       "    vertical-align: top;\n",
       "    white-space: nowrap;\n",
       "}\n",
       "\n",
       "table.dataframe th.bottomBorder {\n",
       "    border-bottom-color: var(--bold-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(odd) {\n",
       "    background: var(--background-odd);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(even) {\n",
       "    background: var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:hover {\n",
       "    background: var(--background-hover);\n",
       "}\n",
       "\n",
       "table.dataframe a {\n",
       "    cursor: pointer;\n",
       "    color: var(--link-color);\n",
       "    text-decoration: none;\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover > td a {\n",
       "    color: var(--link-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe a:hover {\n",
       "    color: var(--link-hover);\n",
       "    text-decoration: underline;\n",
       "}\n",
       "\n",
       "table.dataframe img {\n",
       "    max-width: fit-content;\n",
       "}\n",
       "\n",
       "table.dataframe th.complex {\n",
       "    background-color: var(--background);\n",
       "    border: 1px solid var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe .leftBorder {\n",
       "    border-left-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightBorder {\n",
       "    border-right-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightAlign {\n",
       "    text-align: right;\n",
       "}\n",
       "\n",
       "table.dataframe .expanderSvg {\n",
       "    width: 8px;\n",
       "    height: 8px;\n",
       "    margin-right: 3px;\n",
       "}\n",
       "\n",
       "table.dataframe .expander {\n",
       "    display: flex;\n",
       "    align-items: center;\n",
       "}\n",
       "\n",
       "/* formatting */\n",
       "\n",
       "table.dataframe .null {\n",
       "    color: var(--text-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe .structural {\n",
       "    color: var(--text-color-medium);\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .dataFrameCaption {\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .numbers {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe td:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "\n",
       ":root {\n",
       "    --background: #fff;\n",
       "    --background-odd: #f5f5f5;\n",
       "    --background-hover: #d9edfd;\n",
       "    --header-text-color: #474747;\n",
       "    --text-color: #848484;\n",
       "    --text-color-dark: #000;\n",
       "    --text-color-medium: #737373;\n",
       "    --text-color-pale: #b3b3b3;\n",
       "    --inner-border-color: #aaa;\n",
       "    --bold-border-color: #000;\n",
       "    --link-color: #296eaa;\n",
       "    --link-color-pale: #296eaa;\n",
       "    --link-hover: #1a466c;\n",
       "}\n",
       "\n",
       ":root[theme=\"dark\"], :root [data-jp-theme-light=\"false\"], .dataframe_dark{\n",
       "    --background: #303030;\n",
       "    --background-odd: #3c3c3c;\n",
       "    --background-hover: #464646;\n",
       "    --header-text-color: #dddddd;\n",
       "    --text-color: #b3b3b3;\n",
       "    --text-color-dark: #dddddd;\n",
       "    --text-color-medium: #b2b2b2;\n",
       "    --text-color-pale: #737373;\n",
       "    --inner-border-color: #707070;\n",
       "    --bold-border-color: #777777;\n",
       "    --link-color: #008dc0;\n",
       "    --link-color-pale: #97e1fb;\n",
       "    --link-hover: #00688e;\n",
       "}\n",
       "\n",
       "p.dataframe_description {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe {\n",
       "    font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n",
       "    font-size: 12px;\n",
       "    background-color: var(--background);\n",
       "    color: var(--text-color-dark);\n",
       "    border: none;\n",
       "    border-collapse: collapse;\n",
       "}\n",
       "\n",
       "table.dataframe th, td {\n",
       "    padding: 6px;\n",
       "    border: 1px solid transparent;\n",
       "    text-align: left;\n",
       "}\n",
       "\n",
       "table.dataframe th {\n",
       "    background-color: var(--background);\n",
       "    color: var(--header-text-color);\n",
       "}\n",
       "\n",
       "table.dataframe td {\n",
       "    vertical-align: top;\n",
       "    white-space: nowrap;\n",
       "}\n",
       "\n",
       "table.dataframe th.bottomBorder {\n",
       "    border-bottom-color: var(--bold-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(odd) {\n",
       "    background: var(--background-odd);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(even) {\n",
       "    background: var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:hover {\n",
       "    background: var(--background-hover);\n",
       "}\n",
       "\n",
       "table.dataframe a {\n",
       "    cursor: pointer;\n",
       "    color: var(--link-color);\n",
       "    text-decoration: none;\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover > td a {\n",
       "    color: var(--link-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe a:hover {\n",
       "    color: var(--link-hover);\n",
       "    text-decoration: underline;\n",
       "}\n",
       "\n",
       "table.dataframe img {\n",
       "    max-width: fit-content;\n",
       "}\n",
       "\n",
       "table.dataframe th.complex {\n",
       "    background-color: var(--background);\n",
       "    border: 1px solid var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe .leftBorder {\n",
       "    border-left-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightBorder {\n",
       "    border-right-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightAlign {\n",
       "    text-align: right;\n",
       "}\n",
       "\n",
       "table.dataframe .expanderSvg {\n",
       "    width: 8px;\n",
       "    height: 8px;\n",
       "    margin-right: 3px;\n",
       "}\n",
       "\n",
       "table.dataframe .expander {\n",
       "    display: flex;\n",
       "    align-items: center;\n",
       "}\n",
       "\n",
       "/* formatting */\n",
       "\n",
       "table.dataframe .null {\n",
       "    color: var(--text-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe .structural {\n",
       "    color: var(--text-color-medium);\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .dataFrameCaption {\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .numbers {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe td:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "\n",
       "            </style>\n",
       "        </head>\n",
       "        <body>\n",
       "            <table class=\"dataframe\" id=\"df_1828716544\"></table>\n",
       "\n",
       "<p class=\"dataframe_description\">DataFrame: rowsCount = 5, columnsCount = 10</p>\n",
       "<table class=\"dataframe\" id=\"static_df_1828716545\"><thead><tr><th class=\"bottomBorder\" style=\"text-align:left\">carat</th><th class=\"bottomBorder\" style=\"text-align:left\">cut</th><th class=\"bottomBorder\" style=\"text-align:left\">color</th><th class=\"bottomBorder\" style=\"text-align:left\">clarity</th><th class=\"bottomBorder\" style=\"text-align:left\">depth</th><th class=\"bottomBorder\" style=\"text-align:left\">table</th><th class=\"bottomBorder\" style=\"text-align:left\">price</th><th class=\"bottomBorder\" style=\"text-align:left\">x</th><th class=\"bottomBorder\" style=\"text-align:left\">y</th><th class=\"bottomBorder\" style=\"text-align:left\">z</th></tr></thead><tbody><tr><td  style=\"vertical-align:top\">0.230000</td><td  style=\"vertical-align:top\">Ideal</td><td  style=\"vertical-align:top\">E</td><td  style=\"vertical-align:top\">SI2</td><td  style=\"vertical-align:top\">61.500000</td><td  style=\"vertical-align:top\">55.000000</td><td  style=\"vertical-align:top\">326</td><td  style=\"vertical-align:top\">3.950000</td><td  style=\"vertical-align:top\">3.980000</td><td  style=\"vertical-align:top\">2.430000</td></tr><tr><td  style=\"vertical-align:top\">0.210000</td><td  style=\"vertical-align:top\">Premium</td><td  style=\"vertical-align:top\">E</td><td  style=\"vertical-align:top\">SI1</td><td  style=\"vertical-align:top\">59.800000</td><td  style=\"vertical-align:top\">61.000000</td><td  style=\"vertical-align:top\">326</td><td  style=\"vertical-align:top\">3.890000</td><td  style=\"vertical-align:top\">3.840000</td><td  style=\"vertical-align:top\">2.310000</td></tr><tr><td  style=\"vertical-align:top\">0.230000</td><td  style=\"vertical-align:top\">Good</td><td  style=\"vertical-align:top\">E</td><td  style=\"vertical-align:top\">VS1</td><td  style=\"vertical-align:top\">56.900000</td><td  style=\"vertical-align:top\">65.000000</td><td  style=\"vertical-align:top\">327</td><td  style=\"vertical-align:top\">4.050000</td><td  style=\"vertical-align:top\">4.070000</td><td  style=\"vertical-align:top\">2.310000</td></tr><tr><td  style=\"vertical-align:top\">0.290000</td><td  style=\"vertical-align:top\">Premium</td><td  style=\"vertical-align:top\">I</td><td  style=\"vertical-align:top\">VS2</td><td  style=\"vertical-align:top\">62.400000</td><td  style=\"vertical-align:top\">58.000000</td><td  style=\"vertical-align:top\">334</td><td  style=\"vertical-align:top\">4.200000</td><td  style=\"vertical-align:top\">4.230000</td><td  style=\"vertical-align:top\">2.630000</td></tr><tr><td  style=\"vertical-align:top\">0.310000</td><td  style=\"vertical-align:top\">Good</td><td  style=\"vertical-align:top\">J</td><td  style=\"vertical-align:top\">SI2</td><td  style=\"vertical-align:top\">63.300000</td><td  style=\"vertical-align:top\">58.000000</td><td  style=\"vertical-align:top\">335</td><td  style=\"vertical-align:top\">4.340000</td><td  style=\"vertical-align:top\">4.350000</td><td  style=\"vertical-align:top\">2.750000</td></tr></tbody></table>\n",
       "        </body>\n",
       "        <script>\n",
       "            /*<!--*/\n",
       "call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: \"<span title=\\\"carat: Double\\\">carat</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">0.23</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">0.21</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">0.23</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">0.29</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">0.31</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"cut: String\\\">cut</span>\", children: [], rightAlign: false, values: [\"Ideal\",\"Premium\",\"Good\",\"Premium\",\"Good\"] }, \n",
       "{ name: \"<span title=\\\"color: Char\\\">color</span>\", children: [], rightAlign: false, values: [\"E\",\"E\",\"E\",\"I\",\"J\"] }, \n",
       "{ name: \"<span title=\\\"clarity: String\\\">clarity</span>\", children: [], rightAlign: false, values: [\"SI2\",\"SI1\",\"VS1\",\"VS2\",\"SI2\"] }, \n",
       "{ name: \"<span title=\\\"depth: Double\\\">depth</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">61.5</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">59.8</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">56.9</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">62.4</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">63.3</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"table: Double\\\">table</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">55.0</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">61.0</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">65.0</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">58.0</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">58.0</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"price: Int\\\">price</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">326</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">326</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">327</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">334</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">335</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"x: Double\\\">x</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">3.95</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">3.89</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">4.05</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">4.20</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">4.34</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"y: Double\\\">y</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">3.98</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">3.84</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">4.07</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">4.23</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">4.35</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"z: Double\\\">z</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">2.43</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">2.31</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">2.31</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">2.63</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">2.75</span></span>\"] }, \n",
       "], id: 1828716544, rootId: 1828716544, totalRows: 5 } ) });\n",
       "/*-->*/\n",
       "\n",
       "call_DataFrame(function() { DataFrame.renderTable(1828716544) });\n",
       "\n",
       "document.getElementById(\"static_df_1828716545\").style.display = \"none\";\n",
       "        </script>\n",
       "        </html>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val url = \"https://raw.githubusercontent.com/JetBrains/lets-plot-docs/refs/heads/master/data/diamonds.csv\"\n",
    "val df = DataFrame.readCSV(url)\n",
    "val data = df.toMap()\n",
    "println(\"${df.rowsCount()} x ${df.columnsCount()}\")\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0730e10d-23ca-45ad-a9ad-6582b95d314e",
   "metadata": {},
   "source": [
    "## Default Bins"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "e36cc653-252d-4f83-9d2f-61955bd4cf35",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"4PFSDO\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"library\">\n",
       "       if(!window.letsPlotCallQueue) {\n",
       "           window.letsPlotCallQueue = [];\n",
       "       }; \n",
       "       window.letsPlotCall = function(f) {\n",
       "           window.letsPlotCallQueue.push(f);\n",
       "       };\n",
       "       (function() {\n",
       "           var script = document.createElement(\"script\");\n",
       "           script.type = \"text/javascript\";\n",
       "           script.src = \"https://cdn.jsdelivr.net/gh/JetBrains/lets-plot@v4.8.1rc1/js-package/distr/lets-plot.min.js\";\n",
       "           script.onload = function() {\n",
       "               window.letsPlotCall = function(f) {f();};\n",
       "               window.letsPlotCallQueue.forEach(function(f) {f();});\n",
       "               window.letsPlotCallQueue = [];\n",
       "               \n",
       "               \n",
       "           };\n",
       "           script.onerror = function(event) {\n",
       "               window.letsPlotCall = function(f) {};\n",
       "               window.letsPlotCallQueue = [];\n",
       "               var div = document.createElement(\"div\");\n",
       "               div.style.color = 'darkred';\n",
       "               div.textContent = 'Error loading Lets-Plot JS';\n",
       "               document.getElementById(\"4PFSDO\").appendChild(div);\n",
       "           };\n",
       "           var e = document.getElementById(\"4PFSDO\");\n",
       "           e.appendChild(script);\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "   <div id=\"DUwhuw\" ></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "   \n",
       "   (function() {\n",
       "   // ----------\n",
       "   \n",
       "   const forceImmediateRender = false;\n",
       "   const responsive = false;\n",
       "   \n",
       "   let sizing = {\n",
       "       width_mode: \"MIN\",\n",
       "       height_mode: \"SCALED\",\n",
       "       width: null, \n",
       "       height: null \n",
       "   };\n",
       "   \n",
       "   const preferredWidth = document.body.dataset.letsPlotPreferredWidth;\n",
       "   if (preferredWidth !== undefined) {\n",
       "       sizing = {\n",
       "           width_mode: 'FIXED',\n",
       "           height_mode: 'SCALED',\n",
       "           width: parseFloat(preferredWidth)\n",
       "       };\n",
       "   }\n",
       "   \n",
       "   const containerDiv = document.getElementById(\"DUwhuw\");\n",
       "   let fig = null;\n",
       "   \n",
       "   function renderPlot() {\n",
       "       if (fig === null) {\n",
       "           const plotSpec = {\n",
       "\"mapping\":{\n",
       "\"x\":\"price\"\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"bin\",\n",
       "\"color\":\"black\",\n",
       "\"position\":\"stack\",\n",
       "\"geom\":\"histogram\",\n",
       "\"fill\":\"gray80\",\n",
       "\"data\":{\n",
       "\"price\":[217.07322222222217,862.4129999999999,1507.7527777777777,2153.0925555555555,2798.432333333333,3443.772111111111,4089.1118888888886,4734.451666666667,5379.791444444444,6025.131222222221,6670.471,7315.810777777778,7961.150555555555,8606.490333333331,9251.83011111111,9897.169888888888,10542.509666666665,11187.849444444442,11833.18922222222,12478.528999999999,13123.868777777776,13769.208555555553,14414.548333333332,15059.88811111111,15705.227888888887,16350.567666666664,16995.90744444444,17641.24722222222,18286.587,18931.926777777775],\n",
       "\"..count..\":[2531.0,14873.0,5464.0,4531.0,3469.0,2721.0,2964.0,2931.0,2115.0,1660.0,1391.0,1151.0,907.0,839.0,751.0,644.0,590.0,580.0,464.0,465.0,413.0,367.0,353.0,307.0,324.0,276.0,296.0,241.0,257.0,65.0]\n",
       "}\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"carat\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"cut\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"clarity\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"depth\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"table\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"price\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"z\"\n",
       "}]\n",
       "},\n",
       "\"spec_id\":\"1\"\n",
       "};\n",
       "           window.letsPlotCall(function() { fig = LetsPlot.buildPlotFromProcessedSpecs(plotSpec, containerDiv, sizing); });\n",
       "       } else {\n",
       "           fig.updateView({});\n",
       "       }\n",
       "   }\n",
       "   \n",
       "   const renderImmediately = \n",
       "       forceImmediateRender || (\n",
       "           sizing.width_mode === 'FIXED' && \n",
       "           (sizing.height_mode === 'FIXED' || sizing.height_mode === 'SCALED')\n",
       "       );\n",
       "   \n",
       "   if (renderImmediately) {\n",
       "       renderPlot();\n",
       "   }\n",
       "   \n",
       "   if (!renderImmediately || responsive) {\n",
       "       // Set up observer for initial sizing or continuous monitoring\n",
       "       var observer = new ResizeObserver(function(entries) {\n",
       "           for (let entry of entries) {\n",
       "               if (entry.contentBoxSize && \n",
       "                   entry.contentBoxSize[0].inlineSize > 0) {\n",
       "                   if (!responsive && observer) {\n",
       "                       observer.disconnect();\n",
       "                       observer = null;\n",
       "                   }\n",
       "                   renderPlot();\n",
       "                   if (!responsive) {\n",
       "                       break;\n",
       "                   }\n",
       "               }\n",
       "           }\n",
       "       });\n",
       "       \n",
       "       observer.observe(containerDiv);\n",
       "   }\n",
       "   \n",
       "   // ----------\n",
       "   })();\n",
       "   \n",
       "   </script>                <svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" display=\"block\" class=\"plt-container\" id=14aef4e8-6934-4acb-8003-add4028d56ba width=\"100%\" height=\"100%\" style=\"max-width: 600.0px; max-height: 400.0px;\" viewBox=\"0 0 600.0 400.0\" preserveAspectRatio=\"xMinYMin meet\">\n",
       "  <style type=\"text/css\">\n",
       "  .plt-container {\n",
       "   font-family: sans-serif;\n",
       "   user-select: none;\n",
       "   -webkit-user-select: none;\n",
       "   -moz-user-select: none;\n",
       "   -ms-user-select: none;\n",
       "}\n",
       "text {\n",
       "   text-rendering: optimizeLegibility;\n",
       "}\n",
       "#pFoUb0M .plot-title {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 16.0px;\n",
       "\n",
       "}\n",
       "#pFoUb0M .plot-subtitle {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 15.0px;\n",
       "\n",
       "}\n",
       "#pFoUb0M .plot-caption {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#pFoUb0M .hyperlink-element {\n",
       "fill: #118ed8;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "\n",
       "}\n",
       "#pFoUb0M .legend-title {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 15.0px;\n",
       "\n",
       "}\n",
       "#pFoUb0M .legend-item {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#pFoUb0M .axis-title-x {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 15.0px;\n",
       "\n",
       "}\n",
       "#pFoUb0M .axis-text-x {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#dEGYQMi .axis-tooltip-text-x {\n",
       "fill: #ffffff;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#pFoUb0M .axis-title-y {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 15.0px;\n",
       "\n",
       "}\n",
       "#pFoUb0M .axis-text-y {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#dEGYQMi .axis-tooltip-text-y {\n",
       "fill: #ffffff;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#pFoUb0M .facet-strip-text-x {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#pFoUb0M .facet-strip-text-y {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#dEGYQMi .tooltip-text {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#dEGYQMi .tooltip-title {\n",
       "fill: #474747;\n",
       "font-weight: bold;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#dEGYQMi .tooltip-label {\n",
       "fill: #474747;\n",
       "font-weight: bold;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "\n",
       "  </style>\n",
       "  <g id=\"pFoUb0M\">\n",
       "    <path fill-rule=\"evenodd\" fill=\"rgb(255,255,255)\" fill-opacity=\"1.0\" d=\"M0.0 0.0 L0.0 400.0 L600.0 400.0 L600.0 0.0 Z\">\n",
       "    </path>\n",
       "    <g transform=\"translate(21.0 6.0 ) \">\n",
       "      <g>\n",
       "        <g transform=\"translate(46.97651758668602 0.0 ) \">\n",
       "          <g>\n",
       "            <line x1=\"26.518430813988648\" y1=\"0.0\" x2=\"26.518430813988648\" y2=\"354.0\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"150.02008123576962\" y1=\"0.0\" x2=\"150.02008123576962\" y2=\"354.0\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"273.5217316575506\" y1=\"0.0\" x2=\"273.5217316575506\" y2=\"354.0\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"397.02338207933155\" y1=\"0.0\" x2=\"397.02338207933155\" y2=\"354.0\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"520.5250325011126\" y1=\"0.0\" x2=\"520.5250325011126\" y2=\"354.0\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "          </g>\n",
       "        </g>\n",
       "        <g transform=\"translate(46.97651758668602 0.0 ) \">\n",
       "          <g>\n",
       "            <line x1=\"0.0\" y1=\"354.0\" x2=\"526.023482413314\" y2=\"354.0\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"0.0\" y1=\"308.6637723199278\" x2=\"526.023482413314\" y2=\"308.6637723199278\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"0.0\" y1=\"263.32754463985555\" x2=\"526.023482413314\" y2=\"263.32754463985555\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"0.0\" y1=\"217.9913169597833\" x2=\"526.023482413314\" y2=\"217.9913169597833\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"0.0\" y1=\"172.65508927971106\" x2=\"526.023482413314\" y2=\"172.65508927971106\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"0.0\" y1=\"127.31886159963884\" x2=\"526.023482413314\" y2=\"127.31886159963884\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"0.0\" y1=\"81.98263391956658\" x2=\"526.023482413314\" y2=\"81.98263391956658\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"0.0\" y1=\"36.646406239494354\" x2=\"526.023482413314\" y2=\"36.646406239494354\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "          </g>\n",
       "        </g>\n",
       "      </g>\n",
       "      <g clip-path=\"url(#cqEJLmT)\" clip-bounds-jfx=\"[rect (46.97651758668602, 0.0), (526.023482413314, 354.0)]\">\n",
       "        <g transform=\"translate(46.97651758668602 0.0 ) \">\n",
       "          <g>\n",
       "            <g>\n",
       "              <rect x=\"486.1732185941235\" y=\"352.5265726003976\" height=\"1.4734273996023717\" width=\"15.940105527676224\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"470.2331130664475\" y=\"348.1742947431107\" height=\"5.825705256889307\" width=\"15.940105527675996\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"454.2930075387713\" y=\"348.5369845645513\" height=\"5.46301543544871\" width=\"15.940105527676053\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"438.35290201109507\" y=\"347.2902383033493\" height=\"6.7097616966506735\" width=\"15.940105527676053\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"422.41279648341884\" y=\"347.74360058015003\" height=\"6.25639941984997\" width=\"15.94010552767611\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"406.4726909557427\" y=\"346.6555311158283\" height=\"7.344468884171704\" width=\"15.94010552767611\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"390.5325854280665\" y=\"347.04088905110893\" height=\"6.959110948891066\" width=\"15.94010552767611\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"374.59247990039034\" y=\"345.9981558144672\" height=\"8.001844185532775\" width=\"15.94010552767611\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"358.6523743727141\" y=\"345.68080222070677\" height=\"8.319197779293233\" width=\"15.94010552767611\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"342.71226884503795\" y=\"344.63806898406506\" height=\"9.361931015934942\" width=\"15.94010552767611\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"326.7721633173618\" y=\"343.4593270643832\" height=\"10.540672935616783\" width=\"15.94010552767611\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"310.83205778968556\" y=\"343.48199517822326\" height=\"10.518004821776742\" width=\"15.94010552767611\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"294.89195226200934\" y=\"340.85249397277903\" height=\"13.14750602722097\" width=\"15.940105527676167\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"278.95184673433323\" y=\"340.6258128343787\" height=\"13.374187165621322\" width=\"15.94010552767611\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"263.011741206657\" y=\"339.40173468701676\" height=\"14.598265312983244\" width=\"15.940105527676167\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"247.07163567898087\" y=\"336.9762465061329\" height=\"17.023753493867105\" width=\"15.940105527676138\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"231.13153015130464\" y=\"334.9814524882097\" height=\"19.018547511790302\" width=\"15.940105527676138\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"215.1914246236285\" y=\"333.44002074708726\" height=\"20.55997925291274\" width=\"15.94010552767611\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"199.25131909595234\" y=\"327.9090009701184\" height=\"26.090999029881573\" width=\"15.94010552767611\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"183.31121356827614\" y=\"322.46865364850976\" height=\"31.531346351490242\" width=\"15.94010552767611\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"167.37110804059995\" y=\"316.37093102554\" height=\"37.62906897445998\" width=\"15.94010552767611\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"151.43100251292375\" y=\"306.0569392283236\" height=\"47.943060771676414\" width=\"15.940105527676138\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"135.4908969852476\" y=\"287.5597583348541\" height=\"66.44024166514589\" width=\"15.940105527676138\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"119.55079145757138\" y=\"286.81171057813293\" height=\"67.18828942186707\" width=\"15.940105527676153\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"103.6106859298952\" y=\"292.3200622412617\" height=\"61.679937758738276\" width=\"15.940105527676124\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"87.67058040221902\" y=\"275.36431308891474\" height=\"78.63568691108526\" width=\"15.940105527676124\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"71.73047487454284\" y=\"251.29077619079635\" height=\"102.70922380920365\" width=\"15.940105527676124\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"55.79036934686665\" y=\"230.14142597804266\" height=\"123.85857402195734\" width=\"15.940105527676131\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"39.85026381919046\" y=\"16.857142857142833\" height=\"337.14285714285717\" width=\"15.940105527676131\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"23.910158291514275\" y=\"296.6270038708686\" height=\"57.37299612913142\" width=\"15.940105527676128\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "            </g>\n",
       "          </g>\n",
       "        </g>\n",
       "        <defs>\n",
       "          <clipPath id=\"cqEJLmT\">\n",
       "            <rect x=\"46.97651758668602\" y=\"0.0\" width=\"526.023482413314\" height=\"354.0\">\n",
       "            </rect>\n",
       "          </clipPath>\n",
       "        </defs>\n",
       "      </g>\n",
       "      <g>\n",
       "        <g transform=\"translate(46.97651758668602 354.0 ) \">\n",
       "          <g transform=\"translate(26.518430813988648 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>0</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(150.02008123576962 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>5,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(273.5217316575506 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>10,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(397.02338207933155 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>15,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(520.5250325011126 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>20,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <line x1=\"0.0\" y1=\"0.0\" x2=\"526.023482413314\" y2=\"0.0\" stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\">\n",
       "          </line>\n",
       "        </g>\n",
       "        <g transform=\"translate(46.97651758668602 0.0 ) \">\n",
       "          <g transform=\"translate(0.0 354.0 ) \">\n",
       "            <g transform=\"translate(-2.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>0</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(0.0 308.6637723199278 ) \">\n",
       "            <g transform=\"translate(-2.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>2,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(0.0 263.32754463985555 ) \">\n",
       "            <g transform=\"translate(-2.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>4,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(0.0 217.9913169597833 ) \">\n",
       "            <g transform=\"translate(-2.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>6,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(0.0 172.65508927971106 ) \">\n",
       "            <g transform=\"translate(-2.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>8,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(0.0 127.31886159963884 ) \">\n",
       "            <g transform=\"translate(-2.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>10,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(0.0 81.98263391956658 ) \">\n",
       "            <g transform=\"translate(-2.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>12,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(0.0 36.646406239494354 ) \">\n",
       "            <g transform=\"translate(-2.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>14,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "        </g>\n",
       "      </g>\n",
       "    </g>\n",
       "    <g transform=\"translate(15.0 183.0 ) rotate(-90.0 ) \">\n",
       "      <text style=\"font-size:15.0px;\" y=\"0.0\" class=\"axis-title-y\" text-anchor=\"middle\">\n",
       "        <tspan>count</tspan>\n",
       "      </text>\n",
       "    </g>\n",
       "    <g transform=\"translate(330.988258793343 394.0 ) \">\n",
       "      <text style=\"font-size:15.0px;\" y=\"0.0\" class=\"axis-title-x\" text-anchor=\"middle\">\n",
       "        <tspan>price</tspan>\n",
       "      </text>\n",
       "    </g>\n",
       "    <path fill=\"rgb(0,0,0)\" fill-opacity=\"0.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" stroke-width=\"0.0\" d=\"M0.0 0.0 L0.0 400.0 L600.0 400.0 L600.0 0.0 Z\" pointer-events=\"none\">\n",
       "    </path>\n",
       "  </g>\n",
       "  <g id=\"dEGYQMi\">\n",
       "  </g>\n",
       "</svg>\n",
       "                <script>document.getElementById(\"14aef4e8-6934-4acb-8003-add4028d56ba\").style.display = \"none\";</script>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "letsPlot(data) { x = \"price\" } +\n",
    "    geomHistogram(color = \"black\", fill = \"gray80\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5fe3cbbe-39fb-475f-a8b9-9ce5d7fd9bde",
   "metadata": {},
   "source": [
    "## Equi-probable Bins"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "54ff27a9-aee8-4d07-abae-c98c9a62e47a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"61WaAU\" ></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "   \n",
       "   (function() {\n",
       "   // ----------\n",
       "   \n",
       "   const forceImmediateRender = false;\n",
       "   const responsive = false;\n",
       "   \n",
       "   let sizing = {\n",
       "       width_mode: \"MIN\",\n",
       "       height_mode: \"SCALED\",\n",
       "       width: null, \n",
       "       height: null \n",
       "   };\n",
       "   \n",
       "   const preferredWidth = document.body.dataset.letsPlotPreferredWidth;\n",
       "   if (preferredWidth !== undefined) {\n",
       "       sizing = {\n",
       "           width_mode: 'FIXED',\n",
       "           height_mode: 'SCALED',\n",
       "           width: parseFloat(preferredWidth)\n",
       "       };\n",
       "   }\n",
       "   \n",
       "   const containerDiv = document.getElementById(\"61WaAU\");\n",
       "   let fig = null;\n",
       "   \n",
       "   function renderPlot() {\n",
       "       if (fig === null) {\n",
       "           const plotSpec = {\n",
       "\"mapping\":{\n",
       "\"x\":\"price\"\n",
       "},\n",
       "\"data\":{\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"bin\",\n",
       "\"color\":\"black\",\n",
       "\"breaks\":[326.0,646.0,837.0,1087.0,1698.0,2401.0,3465.0,4662.0,6301.199999999997,9821.0,18823.0],\n",
       "\"position\":\"stack\",\n",
       "\"geom\":\"histogram\",\n",
       "\"fill\":\"gray80\",\n",
       "\"data\":{\n",
       "\"price\":[486.0,741.5,962.0,1392.5,2049.5,2933.0,4063.5,5481.5999999999985,8061.0999999999985,14322.0],\n",
       "\"..count..\":[5411.0,5385.0,5396.0,5388.0,5405.0,5384.0,5394.0,5389.0,5395.0,5393.0]\n",
       "}\n",
       "}],\n",
       "\"theme\":{\n",
       "\"name\":\"classic\"\n",
       "},\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"carat\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"cut\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"clarity\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"depth\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"table\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"price\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"x\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"y\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"z\"\n",
       "}]\n",
       "},\n",
       "\"spec_id\":\"3\"\n",
       "};\n",
       "           window.letsPlotCall(function() { fig = LetsPlot.buildPlotFromProcessedSpecs(plotSpec, containerDiv, sizing); });\n",
       "       } else {\n",
       "           fig.updateView({});\n",
       "       }\n",
       "   }\n",
       "   \n",
       "   const renderImmediately = \n",
       "       forceImmediateRender || (\n",
       "           sizing.width_mode === 'FIXED' && \n",
       "           (sizing.height_mode === 'FIXED' || sizing.height_mode === 'SCALED')\n",
       "       );\n",
       "   \n",
       "   if (renderImmediately) {\n",
       "       renderPlot();\n",
       "   }\n",
       "   \n",
       "   if (!renderImmediately || responsive) {\n",
       "       // Set up observer for initial sizing or continuous monitoring\n",
       "       var observer = new ResizeObserver(function(entries) {\n",
       "           for (let entry of entries) {\n",
       "               if (entry.contentBoxSize && \n",
       "                   entry.contentBoxSize[0].inlineSize > 0) {\n",
       "                   if (!responsive && observer) {\n",
       "                       observer.disconnect();\n",
       "                       observer = null;\n",
       "                   }\n",
       "                   renderPlot();\n",
       "                   if (!responsive) {\n",
       "                       break;\n",
       "                   }\n",
       "               }\n",
       "           }\n",
       "       });\n",
       "       \n",
       "       observer.observe(containerDiv);\n",
       "   }\n",
       "   \n",
       "   // ----------\n",
       "   })();\n",
       "   \n",
       "   </script>                <svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" display=\"block\" class=\"plt-container\" id=ee389ba0-23ce-46d7-a0b3-dc6ba095c61c width=\"100%\" height=\"100%\" style=\"max-width: 600.0px; max-height: 400.0px;\" viewBox=\"0 0 600.0 400.0\" preserveAspectRatio=\"xMinYMin meet\">\n",
       "  <style type=\"text/css\">\n",
       "  .plt-container {\n",
       "   font-family: sans-serif;\n",
       "   user-select: none;\n",
       "   -webkit-user-select: none;\n",
       "   -moz-user-select: none;\n",
       "   -ms-user-select: none;\n",
       "}\n",
       "text {\n",
       "   text-rendering: optimizeLegibility;\n",
       "}\n",
       "#pozqGTd .plot-title {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 16.0px;\n",
       "\n",
       "}\n",
       "#pozqGTd .plot-subtitle {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 15.0px;\n",
       "\n",
       "}\n",
       "#pozqGTd .plot-caption {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#pozqGTd .hyperlink-element {\n",
       "fill: #118ed8;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "\n",
       "}\n",
       "#pozqGTd .legend-title {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 15.0px;\n",
       "\n",
       "}\n",
       "#pozqGTd .legend-item {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#pozqGTd .axis-title-x {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 15.0px;\n",
       "\n",
       "}\n",
       "#pozqGTd .axis-text-x {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#dYGyMs7 .axis-tooltip-text-x {\n",
       "fill: #ffffff;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#pozqGTd .axis-title-y {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 15.0px;\n",
       "\n",
       "}\n",
       "#pozqGTd .axis-text-y {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#dYGyMs7 .axis-tooltip-text-y {\n",
       "fill: #ffffff;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#pozqGTd .facet-strip-text-x {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#pozqGTd .facet-strip-text-y {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#dYGyMs7 .tooltip-text {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#dYGyMs7 .tooltip-title {\n",
       "fill: #474747;\n",
       "font-weight: bold;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#dYGyMs7 .tooltip-label {\n",
       "fill: #474747;\n",
       "font-weight: bold;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "\n",
       "  </style>\n",
       "  <g id=\"pozqGTd\">\n",
       "    <path fill-rule=\"evenodd\" fill=\"rgb(255,255,255)\" fill-opacity=\"1.0\" d=\"M0.0 0.0 L0.0 400.0 L600.0 400.0 L600.0 0.0 Z\">\n",
       "    </path>\n",
       "    <g transform=\"translate(21.0 6.0 ) \">\n",
       "      <g>\n",
       "        <g transform=\"translate(42.99591213121782 0.0 ) \">\n",
       "          <g>\n",
       "          </g>\n",
       "        </g>\n",
       "        <g transform=\"translate(42.99591213121782 0.0 ) \">\n",
       "          <g>\n",
       "          </g>\n",
       "        </g>\n",
       "      </g>\n",
       "      <g clip-path=\"url(#cO8l3gX)\" clip-bounds-jfx=\"[rect (42.99591213121782, 0.0), (530.0040878687822, 354.0)]\">\n",
       "        <g transform=\"translate(42.99591213121782 0.0 ) \">\n",
       "          <g>\n",
       "            <g>\n",
       "              <rect x=\"271.42303641276135\" y=\"17.978667793119826\" height=\"336.0213322068802\" width=\"234.4899565528945\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"179.73699452486102\" y=\"17.854053911344636\" height=\"336.14594608865536\" width=\"91.68604188790033\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"137.038045759975\" y=\"18.227895556670262\" height=\"335.77210444332974\" width=\"42.69894876488601\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"105.85781047961346\" y=\"17.91636085223223\" height=\"336.08363914776777\" width=\"31.180235280361543\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"78.14204578595874\" y=\"18.53943026110835\" height=\"335.46056973889165\" width=\"27.71576469365472\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"59.82984411336544\" y=\"17.230984502468516\" height=\"336.7690154975315\" width=\"18.312201672593304\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"43.914118335336276\" y=\"18.290202497557914\" height=\"335.7097975024421\" width=\"15.915725778029163\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"37.401955578368536\" y=\"17.79174697045704\" height=\"336.20825302954296\" width=\"6.51216275696774\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"32.42666323204518\" y=\"18.4771233202207\" height=\"335.5228766797793\" width=\"4.975292346323357\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"24.091094903126468\" y=\"16.85714285714289\" height=\"337.1428571428571\" width=\"8.335568328918711\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "            </g>\n",
       "          </g>\n",
       "        </g>\n",
       "        <defs>\n",
       "          <clipPath id=\"cO8l3gX\">\n",
       "            <rect x=\"42.99591213121782\" y=\"0.0\" width=\"530.0040878687822\" height=\"354.0\">\n",
       "            </rect>\n",
       "          </clipPath>\n",
       "        </defs>\n",
       "      </g>\n",
       "      <g>\n",
       "        <g transform=\"translate(42.99591213121782 354.0 ) \">\n",
       "          <g transform=\"translate(15.599234668040532 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>0</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(67.69653672378247 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>2,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(119.79383877952442 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>4,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(171.89114083526636 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>6,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(223.9884428910083 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>8,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(276.08574494675025 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>10,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(328.1830470024922 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>12,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(380.28034905823415 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>14,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(432.37765111397607 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>16,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(484.47495316971805 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>18,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <line x1=\"0.0\" y1=\"0.0\" x2=\"530.0040878687822\" y2=\"0.0\" stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\">\n",
       "          </line>\n",
       "        </g>\n",
       "        <g transform=\"translate(42.99591213121782 0.0 ) \">\n",
       "          <g transform=\"translate(0.0 354.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"-4.0\" y2=\"0.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(-6.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>0</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(0.0 291.69305911239013 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"-4.0\" y2=\"0.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(-6.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>1,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(0.0 229.3861182247802 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"-4.0\" y2=\"0.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(-6.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>2,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(0.0 167.0791773371703 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"-4.0\" y2=\"0.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(-6.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>3,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(0.0 104.77223644956044 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"-4.0\" y2=\"0.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(-6.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>4,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(0.0 42.46529556195054 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"-4.0\" y2=\"0.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(-6.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>5,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <line x1=\"0.0\" y1=\"0.0\" x2=\"0.0\" y2=\"354.0\" stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\">\n",
       "          </line>\n",
       "        </g>\n",
       "      </g>\n",
       "    </g>\n",
       "    <g transform=\"translate(15.0 183.0 ) rotate(-90.0 ) \">\n",
       "      <text style=\"font-size:15.0px;\" y=\"0.0\" class=\"axis-title-y\" text-anchor=\"middle\">\n",
       "        <tspan>count</tspan>\n",
       "      </text>\n",
       "    </g>\n",
       "    <g transform=\"translate(328.99795606560895 394.0 ) \">\n",
       "      <text style=\"font-size:15.0px;\" y=\"0.0\" class=\"axis-title-x\" text-anchor=\"middle\">\n",
       "        <tspan>price</tspan>\n",
       "      </text>\n",
       "    </g>\n",
       "    <path fill=\"rgb(0,0,0)\" fill-opacity=\"0.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" stroke-width=\"0.0\" d=\"M0.0 0.0 L0.0 400.0 L600.0 400.0 L600.0 0.0 Z\" pointer-events=\"none\">\n",
       "    </path>\n",
       "  </g>\n",
       "  <g id=\"dYGyMs7\">\n",
       "  </g>\n",
       "</svg>\n",
       "                <script>document.getElementById(\"ee389ba0-23ce-46d7-a0b3-dc6ba095c61c\").style.display = \"none\";</script>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val prices = data[\"price\"]\n",
    "    ?.filterIsInstance<Number>()\n",
    "    ?.map(Number::toDouble)\n",
    "    ?.sorted()\n",
    "    ?: emptyList()\n",
    "    \n",
    "val n = prices.size\n",
    "val priceBins = (0..10).map { i ->\n",
    "    val pos = i * (n - 1) / 10.0\n",
    "    val lower = prices[floor(pos).toInt()]\n",
    "    val upper = prices[ceil(pos).toInt()]\n",
    "    lower + (upper - lower) * (pos - floor(pos))\n",
    "}\n",
    "\n",
    "letsPlot(data) { x = \"price\" } +\n",
    "    geomHistogram(\n",
    "        breaks = priceBins,\n",
    "        color = \"black\",\n",
    "        fill = \"gray80\"\n",
    "    ) +\n",
    "    themeClassic()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1edc91c5-18d6-4353-94f6-2b85bb7938bd",
   "metadata": {},
   "source": [
    "## Identity Stat"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "d9e5e106-dbae-4f26-bb14-c6a92e644c9f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/kotlindataframe+json": "{\"nrow\":7,\"ncol\":2,\"columns\":[\"bin_x\",\"count\"],\"is_formatted\":false,\"kotlin_dataframe\":[{\"bin_x\":384.0,\"count\":1997},{\"bin_x\":768.0,\"count\":13008},{\"bin_x\":3072.0,\"count\":10482},{\"bin_x\":6144.0,\"count\":11608},{\"bin_x\":12288.0,\"count\":6369},{\"bin_x\":24576.0,\"count\":979},{\"bin_x\":1536.0,\"count\":9497}]}",
      "text/html": [
       "        <html>\n",
       "        <head>\n",
       "            <style type=\"text/css\">\n",
       "                :root {\n",
       "    --background: #fff;\n",
       "    --background-odd: #f5f5f5;\n",
       "    --background-hover: #d9edfd;\n",
       "    --header-text-color: #474747;\n",
       "    --text-color: #848484;\n",
       "    --text-color-dark: #000;\n",
       "    --text-color-medium: #737373;\n",
       "    --text-color-pale: #b3b3b3;\n",
       "    --inner-border-color: #aaa;\n",
       "    --bold-border-color: #000;\n",
       "    --link-color: #296eaa;\n",
       "    --link-color-pale: #296eaa;\n",
       "    --link-hover: #1a466c;\n",
       "}\n",
       "\n",
       ":root[theme=\"dark\"], :root [data-jp-theme-light=\"false\"], .dataframe_dark{\n",
       "    --background: #303030;\n",
       "    --background-odd: #3c3c3c;\n",
       "    --background-hover: #464646;\n",
       "    --header-text-color: #dddddd;\n",
       "    --text-color: #b3b3b3;\n",
       "    --text-color-dark: #dddddd;\n",
       "    --text-color-medium: #b2b2b2;\n",
       "    --text-color-pale: #737373;\n",
       "    --inner-border-color: #707070;\n",
       "    --bold-border-color: #777777;\n",
       "    --link-color: #008dc0;\n",
       "    --link-color-pale: #97e1fb;\n",
       "    --link-hover: #00688e;\n",
       "}\n",
       "\n",
       "p.dataframe_description {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe {\n",
       "    font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n",
       "    font-size: 12px;\n",
       "    background-color: var(--background);\n",
       "    color: var(--text-color-dark);\n",
       "    border: none;\n",
       "    border-collapse: collapse;\n",
       "}\n",
       "\n",
       "table.dataframe th, td {\n",
       "    padding: 6px;\n",
       "    border: 1px solid transparent;\n",
       "    text-align: left;\n",
       "}\n",
       "\n",
       "table.dataframe th {\n",
       "    background-color: var(--background);\n",
       "    color: var(--header-text-color);\n",
       "}\n",
       "\n",
       "table.dataframe td {\n",
       "    vertical-align: top;\n",
       "    white-space: nowrap;\n",
       "}\n",
       "\n",
       "table.dataframe th.bottomBorder {\n",
       "    border-bottom-color: var(--bold-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(odd) {\n",
       "    background: var(--background-odd);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(even) {\n",
       "    background: var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:hover {\n",
       "    background: var(--background-hover);\n",
       "}\n",
       "\n",
       "table.dataframe a {\n",
       "    cursor: pointer;\n",
       "    color: var(--link-color);\n",
       "    text-decoration: none;\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover > td a {\n",
       "    color: var(--link-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe a:hover {\n",
       "    color: var(--link-hover);\n",
       "    text-decoration: underline;\n",
       "}\n",
       "\n",
       "table.dataframe img {\n",
       "    max-width: fit-content;\n",
       "}\n",
       "\n",
       "table.dataframe th.complex {\n",
       "    background-color: var(--background);\n",
       "    border: 1px solid var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe .leftBorder {\n",
       "    border-left-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightBorder {\n",
       "    border-right-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightAlign {\n",
       "    text-align: right;\n",
       "}\n",
       "\n",
       "table.dataframe .expanderSvg {\n",
       "    width: 8px;\n",
       "    height: 8px;\n",
       "    margin-right: 3px;\n",
       "}\n",
       "\n",
       "table.dataframe .expander {\n",
       "    display: flex;\n",
       "    align-items: center;\n",
       "}\n",
       "\n",
       "/* formatting */\n",
       "\n",
       "table.dataframe .null {\n",
       "    color: var(--text-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe .structural {\n",
       "    color: var(--text-color-medium);\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .dataFrameCaption {\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .numbers {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe td:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "\n",
       ":root {\n",
       "    --background: #fff;\n",
       "    --background-odd: #f5f5f5;\n",
       "    --background-hover: #d9edfd;\n",
       "    --header-text-color: #474747;\n",
       "    --text-color: #848484;\n",
       "    --text-color-dark: #000;\n",
       "    --text-color-medium: #737373;\n",
       "    --text-color-pale: #b3b3b3;\n",
       "    --inner-border-color: #aaa;\n",
       "    --bold-border-color: #000;\n",
       "    --link-color: #296eaa;\n",
       "    --link-color-pale: #296eaa;\n",
       "    --link-hover: #1a466c;\n",
       "}\n",
       "\n",
       ":root[theme=\"dark\"], :root [data-jp-theme-light=\"false\"], .dataframe_dark{\n",
       "    --background: #303030;\n",
       "    --background-odd: #3c3c3c;\n",
       "    --background-hover: #464646;\n",
       "    --header-text-color: #dddddd;\n",
       "    --text-color: #b3b3b3;\n",
       "    --text-color-dark: #dddddd;\n",
       "    --text-color-medium: #b2b2b2;\n",
       "    --text-color-pale: #737373;\n",
       "    --inner-border-color: #707070;\n",
       "    --bold-border-color: #777777;\n",
       "    --link-color: #008dc0;\n",
       "    --link-color-pale: #97e1fb;\n",
       "    --link-hover: #00688e;\n",
       "}\n",
       "\n",
       "p.dataframe_description {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe {\n",
       "    font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n",
       "    font-size: 12px;\n",
       "    background-color: var(--background);\n",
       "    color: var(--text-color-dark);\n",
       "    border: none;\n",
       "    border-collapse: collapse;\n",
       "}\n",
       "\n",
       "table.dataframe th, td {\n",
       "    padding: 6px;\n",
       "    border: 1px solid transparent;\n",
       "    text-align: left;\n",
       "}\n",
       "\n",
       "table.dataframe th {\n",
       "    background-color: var(--background);\n",
       "    color: var(--header-text-color);\n",
       "}\n",
       "\n",
       "table.dataframe td {\n",
       "    vertical-align: top;\n",
       "    white-space: nowrap;\n",
       "}\n",
       "\n",
       "table.dataframe th.bottomBorder {\n",
       "    border-bottom-color: var(--bold-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(odd) {\n",
       "    background: var(--background-odd);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(even) {\n",
       "    background: var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:hover {\n",
       "    background: var(--background-hover);\n",
       "}\n",
       "\n",
       "table.dataframe a {\n",
       "    cursor: pointer;\n",
       "    color: var(--link-color);\n",
       "    text-decoration: none;\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover > td a {\n",
       "    color: var(--link-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe a:hover {\n",
       "    color: var(--link-hover);\n",
       "    text-decoration: underline;\n",
       "}\n",
       "\n",
       "table.dataframe img {\n",
       "    max-width: fit-content;\n",
       "}\n",
       "\n",
       "table.dataframe th.complex {\n",
       "    background-color: var(--background);\n",
       "    border: 1px solid var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe .leftBorder {\n",
       "    border-left-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightBorder {\n",
       "    border-right-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightAlign {\n",
       "    text-align: right;\n",
       "}\n",
       "\n",
       "table.dataframe .expanderSvg {\n",
       "    width: 8px;\n",
       "    height: 8px;\n",
       "    margin-right: 3px;\n",
       "}\n",
       "\n",
       "table.dataframe .expander {\n",
       "    display: flex;\n",
       "    align-items: center;\n",
       "}\n",
       "\n",
       "/* formatting */\n",
       "\n",
       "table.dataframe .null {\n",
       "    color: var(--text-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe .structural {\n",
       "    color: var(--text-color-medium);\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .dataFrameCaption {\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .numbers {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe td:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "\n",
       "            </style>\n",
       "        </head>\n",
       "        <body>\n",
       "            <table class=\"dataframe\" id=\"df_1828716546\"></table>\n",
       "\n",
       "<p class=\"dataframe_description\">DataFrame: rowsCount = 7, columnsCount = 2</p>\n",
       "<table class=\"dataframe\" id=\"static_df_1828716547\"><thead><tr><th class=\"bottomBorder\" style=\"text-align:left\">bin_x</th><th class=\"bottomBorder\" style=\"text-align:left\">count</th></tr></thead><tbody><tr><td  style=\"vertical-align:top\">384.000000</td><td  style=\"vertical-align:top\">1997</td></tr><tr><td  style=\"vertical-align:top\">768.000000</td><td  style=\"vertical-align:top\">13008</td></tr><tr><td  style=\"vertical-align:top\">3072.000000</td><td  style=\"vertical-align:top\">10482</td></tr><tr><td  style=\"vertical-align:top\">6144.000000</td><td  style=\"vertical-align:top\">11608</td></tr><tr><td  style=\"vertical-align:top\">12288.000000</td><td  style=\"vertical-align:top\">6369</td></tr><tr><td  style=\"vertical-align:top\">24576.000000</td><td  style=\"vertical-align:top\">979</td></tr><tr><td  style=\"vertical-align:top\">1536.000000</td><td  style=\"vertical-align:top\">9497</td></tr></tbody></table>\n",
       "        </body>\n",
       "        <script>\n",
       "            /*<!--*/\n",
       "call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: \"<span title=\\\"bin_x: Double\\\">bin_x</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">384.0</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">768.0</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">3072.0</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">6144.0</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">12288.0</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">24576.0</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">1536.0</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"count: Int\\\">count</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">1997</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">13008</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">10482</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">11608</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">6369</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">979</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">9497</span></span>\"] }, \n",
       "], id: 1828716546, rootId: 1828716546, totalRows: 7 } ) });\n",
       "/*-->*/\n",
       "\n",
       "call_DataFrame(function() { DataFrame.renderTable(1828716546) });\n",
       "\n",
       "document.getElementById(\"static_df_1828716547\").style.display = \"none\";\n",
       "        </script>\n",
       "        </html>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val breaks = (0..15).map { 2.0.pow(it) }\n",
    "val centers = breaks.zip(breaks.drop(1)) { a, b -> (a + b) / 2.0 }\n",
    "\n",
    "fun binCenter(v: Double?, breaks: List<Double>): Double? =\n",
    "    if (v == null || v < breaks.first() || v > breaks.last()) null\n",
    "    else breaks.zipWithNext().firstOrNull { (a, b) -> v >= a && v < b }?.let { (a, b) -> (a + b) / 2.0 }\n",
    "\n",
    "val dfWithBin = df\n",
    "    .convert { \"price\"<Number?>() }.to<Double?>()\n",
    "    .add(\"bin_x\") { binCenter(this[\"price\"] as Double?, breaks) }   // bin center, corresponding to current price\n",
    "\n",
    "val aggDf = dfWithBin\n",
    "    .groupBy(\"bin_x\")\n",
    "    .aggregate { count() into \"count\" }                             // aggregated dataframe: bin center -> size of bin\n",
    "\n",
    "aggDf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "1e2e4ff2-5c4c-47e5-94f8-84ae84a1f388",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"P7MSzn\" ></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "   \n",
       "   (function() {\n",
       "   // ----------\n",
       "   \n",
       "   const forceImmediateRender = false;\n",
       "   const responsive = false;\n",
       "   \n",
       "   let sizing = {\n",
       "       width_mode: \"MIN\",\n",
       "       height_mode: \"SCALED\",\n",
       "       width: null, \n",
       "       height: null \n",
       "   };\n",
       "   \n",
       "   const preferredWidth = document.body.dataset.letsPlotPreferredWidth;\n",
       "   if (preferredWidth !== undefined) {\n",
       "       sizing = {\n",
       "           width_mode: 'FIXED',\n",
       "           height_mode: 'SCALED',\n",
       "           width: parseFloat(preferredWidth)\n",
       "       };\n",
       "   }\n",
       "   \n",
       "   const containerDiv = document.getElementById(\"P7MSzn\");\n",
       "   let fig = null;\n",
       "   \n",
       "   function renderPlot() {\n",
       "       if (fig === null) {\n",
       "           const plotSpec = {\n",
       "\"mapping\":{\n",
       "\"x\":\"bin_x\",\n",
       "\"y\":\"count\"\n",
       "},\n",
       "\"guides\":{\n",
       "\"x\":{\n",
       "\"title\":\"price\"\n",
       "}\n",
       "},\n",
       "\"data\":{\n",
       "\"bin_x\":[384.0,768.0,3072.0,6144.0,12288.0,24576.0,1536.0],\n",
       "\"count\":[1997.0,13008.0,10482.0,11608.0,6369.0,979.0,9497.0]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"color\":\"black\",\n",
       "\"breaks\":[1.0,2.0,4.0,8.0,16.0,32.0,64.0,128.0,256.0,512.0,1024.0,2048.0,4096.0,8192.0,16384.0,32768.0],\n",
       "\"position\":\"stack\",\n",
       "\"geom\":\"histogram\",\n",
       "\"fill\":\"gray80\",\n",
       "\"data\":{\n",
       "}\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"bin_x\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"count\"\n",
       "}]\n",
       "},\n",
       "\"spec_id\":\"5\"\n",
       "};\n",
       "           window.letsPlotCall(function() { fig = LetsPlot.buildPlotFromProcessedSpecs(plotSpec, containerDiv, sizing); });\n",
       "       } else {\n",
       "           fig.updateView({});\n",
       "       }\n",
       "   }\n",
       "   \n",
       "   const renderImmediately = \n",
       "       forceImmediateRender || (\n",
       "           sizing.width_mode === 'FIXED' && \n",
       "           (sizing.height_mode === 'FIXED' || sizing.height_mode === 'SCALED')\n",
       "       );\n",
       "   \n",
       "   if (renderImmediately) {\n",
       "       renderPlot();\n",
       "   }\n",
       "   \n",
       "   if (!renderImmediately || responsive) {\n",
       "       // Set up observer for initial sizing or continuous monitoring\n",
       "       var observer = new ResizeObserver(function(entries) {\n",
       "           for (let entry of entries) {\n",
       "               if (entry.contentBoxSize && \n",
       "                   entry.contentBoxSize[0].inlineSize > 0) {\n",
       "                   if (!responsive && observer) {\n",
       "                       observer.disconnect();\n",
       "                       observer = null;\n",
       "                   }\n",
       "                   renderPlot();\n",
       "                   if (!responsive) {\n",
       "                       break;\n",
       "                   }\n",
       "               }\n",
       "           }\n",
       "       });\n",
       "       \n",
       "       observer.observe(containerDiv);\n",
       "   }\n",
       "   \n",
       "   // ----------\n",
       "   })();\n",
       "   \n",
       "   </script>                <svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" display=\"block\" class=\"plt-container\" id=8ad0c5a5-70aa-4586-a609-519dae92affb width=\"100%\" height=\"100%\" style=\"max-width: 600.0px; max-height: 400.0px;\" viewBox=\"0 0 600.0 400.0\" preserveAspectRatio=\"xMinYMin meet\">\n",
       "  <style type=\"text/css\">\n",
       "  .plt-container {\n",
       "   font-family: sans-serif;\n",
       "   user-select: none;\n",
       "   -webkit-user-select: none;\n",
       "   -moz-user-select: none;\n",
       "   -ms-user-select: none;\n",
       "}\n",
       "text {\n",
       "   text-rendering: optimizeLegibility;\n",
       "}\n",
       "#pOkrLU4 .plot-title {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 16.0px;\n",
       "\n",
       "}\n",
       "#pOkrLU4 .plot-subtitle {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 15.0px;\n",
       "\n",
       "}\n",
       "#pOkrLU4 .plot-caption {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#pOkrLU4 .hyperlink-element {\n",
       "fill: #118ed8;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "\n",
       "}\n",
       "#pOkrLU4 .legend-title {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 15.0px;\n",
       "\n",
       "}\n",
       "#pOkrLU4 .legend-item {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#pOkrLU4 .axis-title-x {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 15.0px;\n",
       "\n",
       "}\n",
       "#pOkrLU4 .axis-text-x {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#dCK90iK .axis-tooltip-text-x {\n",
       "fill: #ffffff;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#pOkrLU4 .axis-title-y {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 15.0px;\n",
       "\n",
       "}\n",
       "#pOkrLU4 .axis-text-y {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#dCK90iK .axis-tooltip-text-y {\n",
       "fill: #ffffff;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#pOkrLU4 .facet-strip-text-x {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#pOkrLU4 .facet-strip-text-y {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#dCK90iK .tooltip-text {\n",
       "fill: #474747;\n",
       "font-weight: normal;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#dCK90iK .tooltip-title {\n",
       "fill: #474747;\n",
       "font-weight: bold;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "#dCK90iK .tooltip-label {\n",
       "fill: #474747;\n",
       "font-weight: bold;\n",
       "font-style: normal;\n",
       "font-family: sans-serif;\n",
       "font-size: 13.0px;\n",
       "\n",
       "}\n",
       "\n",
       "  </style>\n",
       "  <g id=\"pOkrLU4\">\n",
       "    <path fill-rule=\"evenodd\" fill=\"rgb(255,255,255)\" fill-opacity=\"1.0\" d=\"M0.0 0.0 L0.0 400.0 L600.0 400.0 L600.0 0.0 Z\">\n",
       "    </path>\n",
       "    <g transform=\"translate(21.0 6.0 ) \">\n",
       "      <g>\n",
       "        <g transform=\"translate(46.97651758668602 0.0 ) \">\n",
       "          <g>\n",
       "            <line x1=\"20.144779033008092\" y1=\"0.0\" x2=\"20.144779033008092\" y2=\"354.0\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"93.68734267570701\" y1=\"0.0\" x2=\"93.68734267570701\" y2=\"354.0\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"167.22990631840594\" y1=\"0.0\" x2=\"167.22990631840594\" y2=\"354.0\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"240.7724699611049\" y1=\"0.0\" x2=\"240.7724699611049\" y2=\"354.0\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"314.3150336038038\" y1=\"0.0\" x2=\"314.3150336038038\" y2=\"354.0\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"387.85759724650273\" y1=\"0.0\" x2=\"387.85759724650273\" y2=\"354.0\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"461.4001608892017\" y1=\"0.0\" x2=\"461.4001608892017\" y2=\"354.0\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "          </g>\n",
       "        </g>\n",
       "        <g transform=\"translate(46.97651758668602 0.0 ) \">\n",
       "          <g>\n",
       "            <line x1=\"0.0\" y1=\"354.0\" x2=\"526.023482413314\" y2=\"354.0\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"0.0\" y1=\"302.1637673519592\" x2=\"526.023482413314\" y2=\"302.1637673519592\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"0.0\" y1=\"250.32753470391845\" x2=\"526.023482413314\" y2=\"250.32753470391845\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"0.0\" y1=\"198.4913020558777\" x2=\"526.023482413314\" y2=\"198.4913020558777\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"0.0\" y1=\"146.65506940783692\" x2=\"526.023482413314\" y2=\"146.65506940783692\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"0.0\" y1=\"94.81883675979617\" x2=\"526.023482413314\" y2=\"94.81883675979617\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "            <line x1=\"0.0\" y1=\"42.98260411175539\" x2=\"526.023482413314\" y2=\"42.98260411175539\" stroke=\"rgb(233,233,233)\" stroke-opacity=\"1.0\" stroke-width=\"1.0\" fill=\"none\">\n",
       "            </line>\n",
       "          </g>\n",
       "        </g>\n",
       "      </g>\n",
       "      <g clip-path=\"url(#cW5fo3h)\" clip-bounds-jfx=\"[rect (46.97651758668602, 0.0), (526.023482413314, 354.0)]\">\n",
       "        <g transform=\"translate(46.97651758668602 0.0 ) \">\n",
       "          <g>\n",
       "            <g>\n",
       "              <rect x=\"35.20629606703283\" y=\"107.8556492707784\" height=\"246.1443507292216\" width=\"15.061517034024739\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"261.12905157740397\" y=\"328.62616411878406\" height=\"25.37383588121594\" width=\"240.98427254439582\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"140.636915305206\" y=\"188.92751713231416\" height=\"165.07248286768584\" width=\"120.49213627219797\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"80.39084716910705\" y=\"53.14250571077139\" height=\"300.8574942892286\" width=\"60.246068136098955\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"50.26781310105757\" y=\"82.3263046916183\" height=\"271.6736953083817\" width=\"30.123034068049478\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"27.67553755002046\" y=\"16.857142857142833\" height=\"337.14285714285717\" width=\"7.530758517012369\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "              <rect x=\"23.91015829151428\" y=\"302.2415217009313\" height=\"51.75847829906871\" width=\"3.765379258506183\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"1.0\" fill=\"rgb(204,204,204)\" fill-opacity=\"1.0\" stroke-width=\"1.1\">\n",
       "              </rect>\n",
       "            </g>\n",
       "          </g>\n",
       "        </g>\n",
       "        <defs>\n",
       "          <clipPath id=\"cW5fo3h\">\n",
       "            <rect x=\"46.97651758668602\" y=\"0.0\" width=\"526.023482413314\" height=\"354.0\">\n",
       "            </rect>\n",
       "          </clipPath>\n",
       "        </defs>\n",
       "      </g>\n",
       "      <g>\n",
       "        <g transform=\"translate(46.97651758668602 354.0 ) \">\n",
       "          <g transform=\"translate(20.144779033008092 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>0</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(93.68734267570701 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>5,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(167.22990631840594 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>10,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(240.7724699611049 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>15,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(314.3150336038038 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>20,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(387.85759724650273 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>25,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(461.4001608892017 0.0 ) \">\n",
       "            <line stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" x2=\"0.0\" y2=\"4.0\">\n",
       "            </line>\n",
       "            <g transform=\"translate(0.0 6.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-x\" text-anchor=\"middle\" dy=\"0.7em\">\n",
       "                <tspan>30,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <line x1=\"0.0\" y1=\"0.0\" x2=\"526.023482413314\" y2=\"0.0\" stroke-width=\"1.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\">\n",
       "          </line>\n",
       "        </g>\n",
       "        <g transform=\"translate(46.97651758668602 0.0 ) \">\n",
       "          <g transform=\"translate(0.0 354.0 ) \">\n",
       "            <g transform=\"translate(-2.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>0</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(0.0 302.1637673519592 ) \">\n",
       "            <g transform=\"translate(-2.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>2,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(0.0 250.32753470391845 ) \">\n",
       "            <g transform=\"translate(-2.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>4,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(0.0 198.4913020558777 ) \">\n",
       "            <g transform=\"translate(-2.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>6,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(0.0 146.65506940783692 ) \">\n",
       "            <g transform=\"translate(-2.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>8,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(0.0 94.81883675979617 ) \">\n",
       "            <g transform=\"translate(-2.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>10,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "          <g transform=\"translate(0.0 42.98260411175539 ) \">\n",
       "            <g transform=\"translate(-2.0 0.0 ) \">\n",
       "              <text style=\"font-size:13.0px;\" y=\"0.0\" class=\"axis-text-y\" text-anchor=\"end\" dy=\"0.35em\">\n",
       "                <tspan>12,000</tspan>\n",
       "              </text>\n",
       "            </g>\n",
       "          </g>\n",
       "        </g>\n",
       "      </g>\n",
       "    </g>\n",
       "    <g transform=\"translate(15.0 183.0 ) rotate(-90.0 ) \">\n",
       "      <text style=\"font-size:15.0px;\" y=\"0.0\" class=\"axis-title-y\" text-anchor=\"middle\">\n",
       "        <tspan>count</tspan>\n",
       "      </text>\n",
       "    </g>\n",
       "    <g transform=\"translate(330.988258793343 394.0 ) \">\n",
       "      <text style=\"font-size:15.0px;\" y=\"0.0\" class=\"axis-title-x\" text-anchor=\"middle\">\n",
       "        <tspan>price</tspan>\n",
       "      </text>\n",
       "    </g>\n",
       "    <path fill=\"rgb(0,0,0)\" fill-opacity=\"0.0\" stroke=\"rgb(71,71,71)\" stroke-opacity=\"1.0\" stroke-width=\"0.0\" d=\"M0.0 0.0 L0.0 400.0 L600.0 400.0 L600.0 0.0 Z\" pointer-events=\"none\">\n",
       "    </path>\n",
       "  </g>\n",
       "  <g id=\"dCK90iK\">\n",
       "  </g>\n",
       "</svg>\n",
       "                <script>document.getElementById(\"8ad0c5a5-70aa-4586-a609-519dae92affb\").style.display = \"none\";</script>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "letsPlot(aggDf.toMap()) {\n",
    "    x = \"bin_x\"\n",
    "    y = \"count\"\n",
    "} + geomHistogram(\n",
    "    stat = Stat.identity,\n",
    "    breaks = breaks,\n",
    "    color = \"black\",\n",
    "    fill = \"gray80\"\n",
    ") + xlab(\"price\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Kotlin",
   "language": "kotlin",
   "name": "kotlin"
  },
  "language_info": {
   "codemirror_mode": "text/x-kotlin",
   "file_extension": ".kt",
   "mimetype": "text/x-kotlin",
   "name": "kotlin",
   "nbconvert_exporter": "",
   "pygments_lexer": "kotlin",
   "version": "2.2.20-Beta2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
